<?php

require "web.config.php";
 
 class columnController
 {

  //----------------后台
 //--------------------------------栏目   
    static $db_hc='home_column'; 
function home_column($param){   
global $m;
   $output = show(self::$db_hc,-1,'id','asc');
   include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
    
    
function home_columnadd($param){    
global $m;
   $output = show(self::$db_hc,$param);
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }
     
     
function home_columnupdate(){
	global $m;
$dt = $_POST['data'];
$id = $_POST['id'];

$myValue =update(self::$db_hc,$dt,$id,("homepage/column/".self::$db_hc));
}

//删除
function home_columndel($id){    
global $m;
$myValue =del(self::$db_hc,$id,SplitUrl("homepage/column/".self::$db_hc));
}  
    
     //富文本上传组件
        function home_columnEditUp($name){         	
global $m;
$myValue =upload_file($name,0,1);  
   }
 


  //单文件上传组件
        function home_columnUp($name){         	
global $m;
$myValue =upload_file($name);  
   }
//--------------------------------帖子   
    static $db_tie='tie'; 
function tie($param){   
global $m;
   $output = show(sprintf('select * from %s m left join user u on m.userId=u.Id order by m.time desc',self::$db_tie),'sql');
   include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
   function tie_json($param){   
global $m;
  $output = show(sprintf('select m.*,u.nickname from %s m left join user u on m.userId=u.Id order by m.time desc',self::$db_tie),'sql');
   show_json(0,$output);
    }      
    
function tieadd($param){    
global $m;
   $output = show(self::$db_tie,$param);
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }
 
function tieview($param){    
global $m;
   $output = show(self::$db_tie,$param);
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }    
     
function tieupdate(){
global $m;
$dt = $_POST['data'];
if(empty($dt)&&!empty($_POST)){
	if(!$m->getLoginState()){
		show_json(0,'请先登录');
	}
	
	$dt=$_POST;
 	$loginId=getSession('loginId');	 
	$dt['userId']=$loginId;
	$dt['time']=getTime(TIMESTAMP);
	$rt=update(self::$db_tie,$dt,$id);
	show_json($rt,$rt);
}
$id = $_POST['id'];
$myValue =update(self::$db_tie,$dt,$id,("homepage/column/".self::$db_tie));
}

//删除
function tiedel($id){    
global $m;
$myValue =del(self::$db_tie,$id,SplitUrl("homepage/column/".self::$db_tie));
}  
    
     //富文本上传组件
        function tieEditUp($name){         	
global $m;
$myValue =upload_file($name,0,2);  
   }


  //单文件上传组件
        function tieUp($name){         	
global $m;
$myValue =upload_file($name);  
   }


//--------------------------------回复   
static $db_comment='comment'; 
function comment($param){   
global $m;
   $output = show(sprintf('select * from %s m left join user u on m.userId=u.Id where m.PageId=%s order by m.time desc',self::$db_comment,$param),'sql');
   include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
   function comment_json($param){   
global $m;
  $output = show(sprintf('SELECT m.*,u.nickname ReceiveN,u.QQ_pic ReceivePic FROM (select m.*,u.nickname,u.QQ_pic from %s m left join user u on m.userId=u.Id) m left join user u on m.ReceiveId=u.Id where m.rowId=0 and m.PageId=%s order by m.time asc',self::$db_comment,$param),'sql');
  
  foreach($output as $k=>$v){
  	$rowId=$v['Id'];
  	$v['comment']= $rowId==0?null:show(sprintf('SELECT m.*,u.nickname ReceiveN,u.QQ_pic ReceivePic FROM (select m.*,u.nickname,u.QQ_pic from %s m left join user u on m.userId=u.Id) m left join user u on m.ReceiveId=u.Id where m.rowId=%s order by m.time asc',self::$db_comment,$rowId),'sql');
  $rt[] =$v;
  };
  
  
   show_json(0,$rt);
    }      
    
      function comment_re_json($param){   
global $m;

  $output = show(sprintf('SELECT m.*,u.nickname ReceiveN,u.QQ_pic ReceivePic FROM (select m.*,u.nickname,u.QQ_pic from %s m left join user u on m.userId=u.Id) m left join user u on m.ReceiveId=u.Id where ',self::$db_comment),'sql');
   show_json(0,$output);
    }      
    
function commentadd($param){    
global $m;
   $output = show(self::$db_comment,$param);
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }
 
function commentview($param){    
global $m;
   $output = show(self::$db_comment,$param);
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }    
     
function commentupdate(){
global $m;
$dt = $_POST['data'];
if(empty($dt)&&!empty($_POST)){
	if(!$m->getLoginState()){
		show_json(0,'请先登录');
	}
	$dt=$_POST;
 	$loginId=getSession('loginId');	 
	$dt['userId']=$loginId;
	$dt['time']=getTime(TIMESTAMP);
	$rt=update(self::$db_comment,$dt,$id);
	show_json($rt,$rt);
}
$id = $_POST['id'];
$myValue =update(self::$db_comment,$dt,$id,("homepage/column/".self::$db_comment));
}

//删除
function commentdel($id){    
global $m;
$myValue =del(self::$db_comment,$id,SplitUrl("homepage/column/".self::$db_comment));
}  
    
     //富文本上传组件
        function commentEditUp($name){         	
global $m;
$myValue =upload_file($name,0,2);  
   }


  //单文件上传组件
        function commentUp($name){         	
global $m;
$myValue =upload_file($name);  
   }


 //--------------------------------留言板

public function message($param){   
global $m;
   $output = show("message",-1,"time",'desc');
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }    
  //--------------------------------链接 
    static $db_hl='home_link'; 
public function home_link($param){   
global $m;
   $output = show(self::$db_hl,-1);
   
    include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
    
    
function home_linkadd($param){    
global $m;
   $output= show(self::$db_hl,$param);  include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');
     }
     
     
function home_linkupdate(){
	
	global $m;
$dt = $_POST['data'];
$id = $_POST['id'];

$myValue =update(self::$db_hl,$dt,$id,("homepage/column/".self::$db_hl));
}

//删除
           function home_linkdel($id){    
global $m;
$myValue =del(self::$db_hl,$id,SplitUrl("homepage/column/".self::$db_hl));
}  




  //--------------------------------音乐 
   static $db_hm='home_music'; 
public function home_music($param){  
	
	 global $m;
   $output = show(self::$db_hm,-1);
  include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
    }     
    
    
function home_musicadd($param){    
global $m;

   $output = $param!=0?show(self::$db_hm,$param):"";
     include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }
     
     
function home_musicupdate(){
	
	global $m;
$dt = $_POST['data'];
$id = $_POST['id'];

$myValue =update(self::$db_hm,$dt,$id,("homepage/column/".self::$db_hm));
}

//删除
           function home_musicdel($id){    
global $m;
$myValue =del(self::$db_hm,$id,SplitUrl("homepage/column/".self::$db_hm));
}  

  //上传组件
         function home_musicUp($name){         	
global $m;
$myValue =upload_file($name);  
   }

  //--------------------------------布局    
    static $db_hlo='home_layout'; 
      static $db_hli='home_layout_img';   
function home_layout($param=1){    
global $m;
$output = show(self::$db_hlo,$param);
$img=show(self::$db_hli);
//var_dump($img);  
 include view(__ROOT__,str_replace('Controller','',__CLASS__),__FUNCTION__,'backShare');//加载视图
     }
    
function home_layoutupdate(){
	
	global $m;
$dt = $_POST['data'];
$id = $_POST['id'];

$myValue =update(self::$db_hlo,$dt,$id,sprintf("homepage/column/%s/1",self::$db_hlo));
}

        //上传组件
        //主页背景图
         function home_layoutPicUp($name){         	
global $m;
$myValue =upload_file($name,"1920*500");
//$dt['img']=$myValue;
//update(self::$db_hli,$dt);
}
     
     
     //图片删除
             function home_layoutPicDel($name){         	
global $_gp,$m;
$id=$_gp['id'];
$img=show(self::$db_hli,$id);
$rt=del(self::$db_hli,$id).',';
$rt.=$m->delfile($img['img']);
show_json(1,$rt);
}
   
   
     
     
 }
  
 
?>